package net.zjitc.springboot_demo1.controller;

import net.zjitc.springboot_demo1.MyDataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.sql.DataSource;

@RestController
public class hellocontroller {

    @Value("${zjitc.url}")
    private String zjitcUrl;

    @Value("${user[0].name}")
    private String name;

    @Autowired
    private DataSource dataSource;

    @Autowired
    private Environment env;

    @Autowired
    private MyDataSource myDataSource;

    @GetMapping("hello")
    public String hello() {
        System.out.println("zjitcUrl: " + zjitcUrl);
        System.out.println("name = " + name);
//        System.out.println("dataSource = " + dataSource);
        System.out.println(env.getProperty("user[1].name"));
        System.out.println(env.getProperty("project.picture"));
        System.out.println(myDataSource);
        return "hello,springboot application";
    }
}
